在sqlserver上,新增table/type/SP
--add table
create table 客戶主檔
(
ID varchar(30) NULL
)
--add type
CREATE TYPE dbo.typ_客戶主檔 AS TABLE
(
ID varchar(30) NULL
)
--add sp
create PROCEDURE [dbo].[SP_Insert_客戶主檔]
@myTableType typ_客戶主檔 readonly
AS
BEGIN
insert into [dbo].客戶主檔 ([ID] )
select * from @myTableType
select @@ROWCOUNT
END
C#就可以直接傳入datatable給sqlserver了
var command = new SqlCommand("SP_Insert_客戶主檔")
command.CommandType = CommandType.StoredProcedure})
var dt = new DataTable(); //create your own data table
command.Parameters.Add(new SqlParameter("@myTableType", dt));
command.ExecuteScalar();